﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WhsFacebook.Net.Web.Facebook.Handlers
{
    /// <summary>
    /// Summary description for TowerImage
    /// </summary>
    public class TowerImage : ImageHttpHandler
    {

        protected override byte[] GetImage(Guid instanceId)
        {
            using (var client = new Database.WhsFacebookEntities())
            {
                var img = client.UserWhsTowerImages.Where(o => o.InstanceId == instanceId).FirstOrDefault();

                if (img == null)
                    throw new ArgumentException("no tower image found for instance: " + instanceId, "instanceId");

                return img.TowerJpeg;
            }
        }
    }
}